View(data.decision)
load("/Users/stomkins/Dropbox (University of Michigan)/HeartStepsV2V3/raw data/data_from_RL_algorithm/service_07_09/user10271/train.Rdata")
load("/Users/stomkins/Dropbox (University of Michigan)/HeartStepsV2V3/raw data/data_from_RL_algorithm/service_07_09/user10237/train.Rdata")
getwd()
setwd(../)
setwd("~/")
ls
setwd("dataverse_files_latest_upload_pa/replication_code")
distance_rep = read_csv("../distance_balance_plot_main.csv")
source("plotting.R")
library(tidyverse)
pdistance = save_balance_plot_diffs(distance,"distance",sd=F,
b_one = c(5000,25000,75000),l_one = c("5,000","25,000","75,000"),
b_two = c(1000,5000),l_two = c("1,000","5,000"))
source("plotting.R")
pdistance = save_balance_plot_diffs(distance,"distance",sd=F,
b_one = c(5000,25000,75000),l_one = c("5,000","25,000","75,000"),
b_two = c(1000,5000),l_two = c("1,000","5,000"))
pdistance = save_balance_plot_diffs(distance_rep,"distance",sd=F,
b_one = c(5000,25000,75000),l_one = c("5,000","25,000","75,000"),
b_two = c(1000,5000),l_two = c("1,000","5,000"))
distance_rep = read_csv("../distance_balance_plot_main.csv")
pdistance = save_balance_plot_diffs(distance_rep,"distance",sd=F,
b_one = c(5000,25000,75000),l_one = c("5,000","25,000","75,000"),
b_two = c(1000,5000),l_two = c("1,000","5,000"))
source("plotting.R")
pdistance = save_balance_plot_diffs(distance_rep,"distance",sd=F,
b_one = c(5000,25000,75000),l_one = c("5,000","25,000","75,000"),
b_two = c(1000,5000),l_two = c("1,000","5,000"))
source("plotting.R")
pdistance = save_balance_plot_diffs(distance_rep,"distance",sd=F,
b_one = c(5000,25000,75000),l_one = c("5,000","25,000","75,000"),
b_two = c(1000,5000),l_two = c("1,000","5,000"))
source("plotting.R")
pdistance = save_balance_plot_diffs(distance_rep,"distance",sd=F,
b_one = c(5000,25000,75000),l_one = c("5,000","25,000","75,000"),
b_two = c(1000,5000),l_two = c("1,000","5,000"))
distance_rep = read_csv("../distance_balance_plot_main.csv")
pdistance = save_balance_plot_diffs(distance_rep,"distance",sd=F,
b_one = c(5000,25000,75000),l_one = c("5,000","25,000","75,000"),
b_two = c(1000,5000),l_two = c("1,000","5,000"))
source("plotting.R")
pdistance = save_balance_plot_diffs(distance_rep,"distance",sd=F,
b_one = c(5000,25000,75000),l_one = c("5,000","25,000","75,000"),
b_two = c(1000,5000),l_two = c("1,000","5,000"))
source("plotting.R")
pdistance = save_balance_plot_diffs(distance_rep,"distance",sd=F,
b_one = c(5000,25000,75000),l_one = c("5,000","25,000","75,000"),
b_two = c(1000,5000),l_two = c("1,000","5,000"))
save_plot("a1.pdf",
pdistance, base_height = 16, base_asp = 1.8,device = cairo_pdf)
pshock  = save_balance_plot_diffs(shock_rep,"shock",sd=F,
b_one = c(500,2500,12500),l_one = c("500","2,500","12,500"),
b_two = c(300,600),l_two = c("300","600"))
shock_rep = read_csv("../shock_balance_plot_main.csv")
pshock  = save_balance_plot_diffs(shock_rep,"shock",sd=F,
b_one = c(500,2500,12500),l_one = c("500","2,500","12,500"),
b_two = c(300,600),l_two = c("300","600"))
save_plot("a4.pdf",
pshock, base_height = 16, base_asp = 1.8,device = cairo_pdf)
real_estate_distance = read_csv("../distance_real_estate_balance_plot.csv")
source("plotting.R")
real_d_balance = plot_real_estate(real_estate_distance,breaks=c(250,1000,2500),
labels = c("250","1,000","2,500"))
real_d_balance
save_plot(paste0("a3.pdf"),
real_d_balance , base_height = 10, base_asp = 1.0,device = cairo_pdf)
real_estate_shock = read_csv("../shock_real_estate_balance_plot.csv")
real_d_balance = plot_real_estate(real_estate_shock,breaks=c(100,500),
labels = c("100","500"))
real_s_balance = plot_real_estate(real_estate_shock,breaks=c(100,500),
labels = c("100","500"))
save_plot(paste0("a6.pdf"),
real_s_balance , base_height = 10, base_asp = 1.0,device = cairo_pdf)
source("plotting.R")
scatter = plot_real_estate_scatter(real_estate_shock )
scatter
scatter = plot_real_estate_scatter(real_estate_distance )
save_plot("a2.pdf",
scatter, base_height = 10, base_asp = 1.0,device = cairo_pdf)
save_plot("a5.pdf",
scatter, base_height = 10, base_asp = 1.0,device = cairo_pdf)
source("plotting.R")
library(tidyverse)
shock_historical_voting =  read_csv("../shock_historical_voting.csv")
historical_plot = historical_voting_plot(shock_historical_voting)
source("plotting.R")
historical_plot = historical_voting_plot(shock_historical_voting)
source("plotting.R")
historical_plot = historical_voting_plot(shock_historical_voting)
save_plot("a7.pdf",
historical_plot, base_height = 10, base_asp = 1.1,device = cairo_pdf)
df_two = read_csv("shock_windows_attributes.csv")
df_two = read_csv("../shock_windows_attributes.csv")
View(df_two)
df_one = read_csv("../shock_windows_votes.csv")
View(df_one)
source("plotting.R")
library(tidyverse)
df_one = read_csv("../distance_windows_votes.csv")
df_two = read_csv("../distance_windows_attributes.csv")
to_render = conditional_distance_replication_windows(df_one,df_two)
p = combine_plots_conditional_distance(to_render)
source("plotting.R")
p = combine_plots_conditional_distance(to_render)
p
save_plot("a8.pdf",
p, base_height = 18, base_asp = 1.5,device = cairo_pdf)
source("plotting.R")
to_render = conditional_distance_replication_windows(df_one,df_two)
p = combine_plots_conditional_distance(to_render)
p
save_plot("a8.pdf",
p, base_height = 18, base_asp = 1.5,device = cairo_pdf)
source("~/dataverse_files_latest_upload_pa/replication_code/replication_main_effect.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_scatter_plots.R")
shock_rep = read_csv("../shock_main_effect_data.csv")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_scatter_plots.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_scatter_plots.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_scatter_plots.R")
p=distance_to_polling_place_scatter_rep(distance_rep)
p
source("~/dataverse_files_latest_upload_pa/replication_code/replication_scatter_plots.R")
save_plot(paste0("figure3a.pdf"),
p, base_height = 10, base_asp = 1.0,device = cairo_pdf)
source("~/dataverse_files_latest_upload_pa/replication_code/replication_scatter_plots.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_scatter_plots.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_figure_seven.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_figure_four.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_figure_four.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_a1-6.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_a1-6.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_a1-6.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_a7.R")
source("~/dataverse_files_latest_upload_pa/replication_code/a8.R")
real_d_scatter = plot_real_estate_scatter(real_estate_distance)
real_d_scatter
source("~/dataverse_files_latest_upload_pa/replication_code/replication_a1-6.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_a9.R")
source("~/dataverse_files_latest_upload_pa/replication_code/a10.R")
source("~/dataverse_files_latest_upload_pa/replication_code/tab_a1.R")
shock = read_csv("../shock_county.csv")
source("~/dataverse_files_latest_upload_pa/replication_code/tab_a1.R")
count_data %>%
filter(state %in% c("ia","in","wi","pa","nc","md") )%>%
group_by(change_type) %>%
summarize(n=n()) %>%
mutate(freq = n / sum(n))
count_data %>%
filter(state %in% c("ia","in","wi","pa","nc","md") )%>%
mutate(uid = paste0(county,'-',state)) %>%
summarize(n=length(unique(uid))) %>%
mutate(freq = n / sum(n))
count_data %>%
filter(state %in% c("ia","in","wi","pa","nc","md") )%>%
mutate(uid = paste0(county,'-',state))%>%
group_by(change_type) %>%
summarize(n=length(unique(uid))) %>%
mutate(freq = n / sum(n))
count_data %>%
filter(state %in% c("ia","in","wi","pa","nc","md") )%>%
group_by(change_type) %>%
summarize(n=n()) %>%
mutate(freq = n / sum(n))
counts = counts %>%
filter(state %in% c("ia","in","wi","pa","nc","md") )
View(counts)
counts = counts %>%
filter(str_c(key,"ia-","in-","wi-","pa-","nc-","md-") )
counts = counts %>%
filter(str_detect(key,"ia-","in-","wi-","pa-","nc-","md-") )
filter(str_detect(key,c("ia-","in-","wi-","pa-","nc-","md-") )
counts = counts %>%
filter(str_detect(key,c("ia-","in-","wi-","pa-","nc-","md-") ))
counts = counts %>%
filter(str_detect(key,"ia-|in-|wi-|pa-|nc-|md-") )
View(counts)
write_csv(counts,"../county_change_counts.csv")
source("~/dataverse_files_latest_upload_pa/replication_code/tab_a1.R")
source("~/dataverse_files_latest_upload_pa/replication_code/a8.R")
sessioninfo()
source("plotting.R")
library(tidyverse)
real_estate_distance = read_csv("../distance_real_estate_balance_plot.csv")
real_d_scatter = plot_real_estate_scatter(real_estate_distance)
source("~/dataverse_files_latest_upload_pa/replication_code/replication_a1-6.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_main_effect.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_scatter_plots.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_scatter_plots.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_figure_seven.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_figure_seven.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_figure_four.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_figure_four.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_a7.R")
sessionInfo()
packageVersion("tidyverse")
packageVersion("fixest")
packageVersion("cowplot")
packageVersion("Cairo")
packageVersion("scales")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_main_effect.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_scatter_plots.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_figure_four.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_figure_seven.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_a1-6.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_a7.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_a9.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_a10.R")
source("~/dataverse_files_latest_upload_pa/replication_code/replication_a8.R")
me = main_effect_rep(distance_rep)
View(me)
distance_rep = read_csv("../distance_main_effect_data.csv")
me = main_effect_rep(distance_rep)
shock_rep = read_csv("../shock_main_effect_data.csv")
me = main_effect_rep(shock_rep)
distance_rep = read_csv("../distance_balance_plot_main.csv")
distance_rep = distance_rep %>%
bin_age()
write_csv(distance_rep,"../distance_balance_plot_main.csv")
distance_rep = read_csv("../shock_balance_plot_main.csv")
write_csv(distance_rep,"../shock_balance_plot_main.csv")
distance_rep = read_csv("../shock_balance_plot_main.csv")
distance_rep = distance_rep %>%
bin_age()
write_csv(distance_rep,"../shock_balance_plot_main.csv")
distance_rep = read_csv("../distance_balance_plot_main.csv")
pdistance = save_balance_plot_diffs(distance_rep,"distance",
b_one = c(5000,25000,75000),l_one = c("5,000","25,000","75,000"),
b_two = c(1000,5000),l_two = c("1,000","5,000"))
shock_rep = read_csv("../shock_balance_plot_main.csv")
pshock  = save_balance_plot_diffs_default(shock_rep,"shock",
b_one = c(500,2500,12500),l_one = c("500","2,500","12,500"),
b_two = c(300,600),l_two = c("300","600"))
shock_rep = read_csv("../shock_balance_plot_main.csv")
pshock  = save_balance_plot_diffs_default(shock_rep,"shock",
b_one = c(500,2500,12500),l_one = c("500","2,500","12,500"),
b_two = c(300,600),l_two = c("300","600"))
log(2)
log(4)
